﻿using System;
using System.Windows.Data;

namespace AnthStat.WPF.Applications.Converters
{
    public sealed class ZScoreToBackgroundBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                var zscore = (double) value;

                if (zscore <= 1.0 && zscore >= -1.0)
                {
                    return System.Windows.Media.Brushes.LightGreen;
                }
                if (zscore <= 2.0 && zscore >= -2.0)
                {
                    return System.Windows.Media.Brushes.Gold;
                }
                if (zscore <= 3.0 && zscore >= -3.0)
                {
                    return System.Windows.Media.Brushes.Salmon;
                }
                if (zscore > 3.0 || zscore < -3.0)
                {
                    return System.Windows.Media.Brushes.Black;
                }
            }
            return System.Windows.SystemColors.ControlBrush;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
